home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / f1ocx / vcform1.3 / VB4 / SSMDI / VTIChild.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-15  |  10.3 KB  |  267 lines

  1. VERSION 4.00
  2. Begin VB.Form VCIChildForm 
  3.    BackColor       =   &H80000005&
  4.    Caption         =   "Sheet"
  5.    ClientHeight    =   2280
  6.    ClientLeft      =   1350
  7.    ClientTop       =   2040
  8.    ClientWidth     =   7335
  9.    ForeColor       =   &H80000008&
  10.    Height          =   2745
  11.    Icon            =   "VTIChild.frx":0000
  12.    Left            =   1260
  13.    LinkTopic       =   "Form1"
  14.    MDIChild        =   -1  'True
  15.    ScaleHeight     =   2280
  16.    ScaleWidth      =   7335
  17.    Top             =   1665
  18.    Width           =   7515
  19.    Begin VCIF1Lib.F1Book SS 
  20.       Height          =   2295
  21.       Left            =   0
  22.       TabIndex        =   0
  23.       Top             =   0
  24.       Width           =   7335
  25.       _version        =   65536
  26.       _extentx        =   12938
  27.       _extenty        =   4048
  28.       _stockprops     =   96
  29.       borderstyle     =   1
  30.       tablename       =   "F1Book1"
  31.       appname         =   ""
  32.       filename        =   "VTIChild.frx":044A
  33.       mouseicon       =   "VTIChild.frx":0A5D
  34.    End
  35. Attribute VB_Name = "VCIChildForm"
  36. Attribute VB_Creatable = False
  37. Attribute VB_Exposed = False
  38. Option Explicit
  39. Option Compare Text
  40. Private Sub UpdateLockStatus()
  41.    MainFrame.FormatEnableProtection.Checked = SS.EnableProtection
  42. End Sub
  43. Private Sub UpdateZoom()
  44.    Dim i%
  45.    Dim TheZoom$
  46.    '' Set the Zoom factor
  47.    TheZoom = Format$(SS.ViewScale, "##0\%")
  48.    For i = 0 To MainFrame.cboZoom.ListCount
  49.       If StrComp(TheZoom, MainFrame.cboZoom.List(i)) = 0 Then
  50.          MainFrame.cboZoom.ListIndex = i
  51.          Exit For
  52.       End If
  53.     Next i
  54. End Sub
  55. Private Sub Form_Activate()
  56.    '' Create the sheet name of blank sheets by adding
  57.    '' the next available number to the name "Sheet"
  58.    If Caption = "Sheet" Then
  59.       gNewSSCount = gNewSSCount + 1
  60.       Caption = Caption & gNewSSCount
  61.       SS.TableName = Caption
  62.       SS.ShowEditBar = True
  63.    End If
  64.    ' Update toolbar color display
  65.    Call UpdateTextAndFillColors
  66. End Sub
  67. Private Sub Form_Load()
  68.    Dim Er As Integer
  69.    '' Whenever a child form loads create a matching
  70.    '' spreadsheet
  71.    Er = SS.InitTable
  72.    Call UpdateCBOFontAndSize
  73.    Call UpdateZoom
  74.    Call UpdateLockStatus       ' Updates the lock status of the selection
  75. End Sub
  76. Private Sub Form_Resize()
  77.    '' Expand the worksheet to fill the child window
  78.    SS.Top = 0
  79.    SS.Left = 0
  80.    SS.Width = ScaleWidth
  81.    SS.Height = ScaleHeight
  82. End Sub
  83. Private Sub SS_GotFocus()
  84.    Call Paint_Reference        ' Update Row/Col Reference Display
  85.    Call UpdateCBOFontAndSize   ' Set the font for the current selection
  86.    Call UpdateFace             ' Set buttons for selction font face
  87.    Call UpdateAlignment        ' Set buttons according to selection alignment
  88.    Call UpdateZoom             ' Update zoom factor
  89.    Call UpdateLockStatus       ' Updates the lock status of the selection
  90.    If SS.PolyEditMode = F1PolyEditModePoints Then
  91.       MainFrame.imgEditPoly.Visible = False
  92.    Else
  93.       MainFrame.imgEditPoly.Visible = True
  94.    End If
  95. End Sub
  96. Private Sub SS_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  97.     Dim SS As Object
  98.     Dim TheRow As Long, TheCol As Long
  99.     Dim TheString As String
  100.     Dim LockedFlag As Boolean, HiddenFlag As Boolean
  101.     Dim TheRule As String, TheMessage As String
  102.     Dim OriginRow%, OriginCol%, DestinRow%, DestinCol%
  103.     Dim fpDestinStartRow%, fpDestinEndRow%, fpDestinStartCol%, fpDestinEndCol%
  104.     Dim TheFormat$
  105.     Dim Pattern%
  106.     Dim crFG&, crBG&
  107.     Dim Horizontal%, Vertical%, Orientation%
  108.     Dim WordWrap As Boolean
  109.     Dim pOutline%, pLeft%, pRight%, pTop%, pBottom%, pShade%
  110.     Dim crOutline&, crLeft&, crRight&, crTop&, crBottom&
  111.     Dim pFont$
  112.     Dim pSize%
  113.     Dim pBold As Boolean, pItalic As Boolean, pUnderline As Boolean, pStrikeout As Boolean
  114.     Dim crColor&
  115.     Dim pFOutline As Boolean, pShadow As Boolean
  116.     Set SS = MainFrame.ActiveForm.SS
  117.     ' If button one and if we are in the format painter mode
  118.     If Button = 1 Then
  119.         If FormatPainterFlag = 2 Then
  120.         
  121.             ' Turn off the Selection Change Event so we don't do all the
  122.             ' toolbar updating while formatting.
  123.             SS.DoSelChange = False
  124.             
  125.             SS.MousePointer = F1Default ' Turn default Pointer back on
  126.             
  127.             fpDestinStartRow = SS.SelStartRow
  128.             fpDestinStartCol = SS.SelStartCol
  129.             fpDestinEndRow = SS.SelEndRow
  130.             fpDestinEndCol = SS.SelEndCol
  131.             
  132.             OriginRow = FmtPntStartRow
  133.             For DestinRow = fpDestinStartRow To fpDestinEndRow
  134.                 OriginCol = FmtPntStartCol
  135.                 For DestinCol = fpDestinStartCol To fpDestinEndCol
  136.                     
  137.                     ' Get the origin format
  138.                     SS.Row = OriginRow
  139.                     SS.Col = OriginCol
  140.                     SS.GetAlignment Horizontal, WordWrap, Vertical, Orientation
  141.                     SS.GetBorder pLeft, pRight, pTop, pBottom, pShade, crLeft, crRight, crTop, crBottom
  142.                     SS.GetFont pFont, pSize, pBold, pItalic, pUnderline, pStrikeout, crColor, pFOutline, pShadow
  143.                     SS.GetPattern Pattern, crFG, crBG
  144.                     TheFormat = SS.NumberFormat
  145.                     
  146.                     ' Set the new format
  147.                     SS.Row = DestinRow
  148.                     SS.Col = DestinCol
  149.                     SS.SetPattern Pattern, crFG, crBG
  150.                     SS.NumberFormat = TheFormat
  151.                     SS.SetAlignment Horizontal, WordWrap, Vertical, Orientation
  152.                     pOutline = -1
  153.                     crOutline = -1
  154.                     SS.SetBorder pOutline, pLeft, pRight, pTop, pBottom, pShade, crOutline, crLeft, crRight, crTop, crBottom
  155.                     SS.SetFont pFont, -pSize, pBold, pItalic, pUnderline, pStrikeout, crColor, pFOutline, pShadow
  156.                     
  157.                     OriginCol = OriginCol + 1
  158.                     If OriginCol > FmtPntEndCol Then OriginCol = FmtPntStartCol
  159.                     
  160.                 Next
  161.                 
  162.                 OriginRow = OriginRow + 1
  163.                 If OriginRow > FmtPntEndRow Then OriginRow = FmtPntStartRow
  164.                 
  165.             Next
  166.             
  167.             ' Turn off format painter
  168.             FormatPainterFlag = 0
  169.             SS.DoSelChange = True
  170.             
  171.         End If
  172.     ' Right button displays a cell description dialog
  173.     Else
  174.         ' Save the object into a variable to save on typing.
  175.         SS.TwipsToRC x, y, TheRow, TheCol
  176.         SS.Row = TheRow
  177.         SS.Col = TheCol
  178.         TheString = "Cell: " + SS.Selection + Chr$(10)
  179.         TheString = TheString + "Value: " + Str$(SS.Number) + Chr$(10)
  180.         TheString = TheString + "Format: " + SS.NumberFormat + Chr$(10)
  181.         TheString = TheString + "Formula: " + SS.Formula + Chr$(10)
  182.         SS.GetValidationRule TheRule, TheMessage
  183.         TheString = TheString + "Validation Rule: " + TheRule + Chr$(10)
  184.         TheString = TheString + "Validation Msg: " + TheMessage + Chr$(10)
  185.         SS.GetProtection LockedFlag, HiddenFlag
  186.         TheString = TheString + "Protection: " + IIf(LockedFlag, "Locked", "Unlocked") + Chr$(10)
  187.         MsgBox TheString
  188.         SS.SetFocus
  189.     End If
  190. End Sub
  191. Private Sub SS_SelChange()
  192.     Call Paint_Reference        ' Update Row/Col Reference Display
  193.     Call UpdateCBOFontAndSize   ' Update the font and size cbos
  194.     Call UpdateFace             ' Set buttons for selction font face
  195.     Call UpdateAlignment        ' Set buttons according to selection alignment
  196.     ' If the format painter command is active then set up for
  197.     ' the mouseup event which will complete the command.
  198.     If FormatPainterFlag = 1 Then
  199.         FormatPainterFlag = 2
  200.         MainFrame.ActiveForm.SS.SetFocus
  201.     End If
  202. End Sub
  203. Private Sub UpdateAlignment()
  204.    Dim WordWrap As Boolean
  205.    Dim i%, Horizontal%, Vertical%, orient%
  206.    For i = 0 To 3
  207.       MainFrame.imgAlign(i).Visible = True
  208.    Next i
  209.    SS.GetAlignment Horizontal, WordWrap, Vertical, orient
  210.    Select Case Horizontal
  211.       Case F1HAlignLeft
  212.          MainFrame.imgAlign(0).Visible = False
  213.       Case F1HAlignCenter
  214.          MainFrame.imgAlign(1).Visible = False
  215.       Case F1HAlignRight
  216.          MainFrame.imgAlign(2).Visible = False
  217.       Case F1HAlignCenterAcrossCells
  218.          MainFrame.imgAlign(3).Visible = False
  219.    End Select
  220. End Sub
  221. Private Sub UpdateCBOFontAndSize()
  222.    Dim i%
  223.    Dim theFont$
  224.    Dim ifBold As Boolean, ifItalic As Boolean, ifUnderline As Boolean, ifStrikeout As Boolean
  225.    Dim ifOutline As Boolean, ifShadow As Boolean
  226.    Dim theSize As Integer
  227.    Dim TheColor&
  228.    Dim sizeString$
  229.    Let theFont = Space$(31)
  230.    SS.GetFont theFont, theSize, ifBold, ifItalic, ifUnderline, ifStrikeout, TheColor, ifOutline, ifShadow
  231.    ''Note that theSize comes back as zero every time
  232.    For i = 0 To Screen.FontCount - 1
  233.       If StrComp(theFont, MainFrame.cboFont.List(i)) = 0 Then
  234.          GoTo FoundFont
  235.       End If
  236.    Next i
  237.    '' Empty selection since font not found
  238.    MainFrame.cboFont.ListIndex = -1
  239.    MainFrame.cboSize.Text = ""
  240.    Exit Sub
  241. FoundFont:
  242.    MainFrame.cboFont.ListIndex = i
  243.    MainFrame.cboSize.Text = Str(theSize / 20)
  244. End Sub
  245. Private Sub UpdateFace()
  246.    Dim i%
  247.    Dim theFont$
  248.    Dim ifBold As Boolean, ifItalic As Boolean, ifUnderline As Boolean, ifStrikeout As Boolean
  249.    Dim ifOutline As Boolean, ifShadow As Boolean
  250.    Dim theSize%
  251.    Dim TheColor&
  252.    For i = 0 To 2
  253.       MainFrame.imgFace(i).Visible = True
  254.    Next i
  255.    Let theFont = Space$(31)
  256.    MainFrame.ActiveForm.SS.GetFont theFont, theSize, ifBold, ifItalic, ifUnderline, ifStrikeout, TheColor, ifOutline, ifShadow
  257.    If ifBold Then                              '' Set the button faces as pressed down or
  258.       MainFrame.imgFace(0).Visible = False     '' popped up according to the current font
  259.    End If                                      '' variables of the active spreadsheet
  260.    If ifItalic Then
  261.       MainFrame.imgFace(1).Visible = False
  262.    End If
  263.    If ifUnderline Then
  264.       MainFrame.imgFace(2).Visible = False
  265.    End If
  266. End Sub
  267.